#ifndef COLLECTION_H
#define COLLECTION_H

// A list of labeled metric objects (i.e., Items),
// plus several operations on the list.

#include <list>
#include <vector>
#include <set>
#include <hash_map>
#include "Item.h"
#include "Categorizer.h"

class Collection {
public:

    // kinds of STL container to use to store the items
    struct Container {
        typedef enum {
            LIST,
            VECTOR,
            SET,
            HASH,
            UNKNOWN
        } Type;
    };

    Collection(Container::Type cont);
    virtual ~Collection();

    // Modifiers:
    void add(Item *item);
    void add(Collection& other);
    void partition(Categorizer& cat, vector<Collection*> parts);
    void clear();

    // Access
    int size();
    Container::Type get_container();

    // Input and Output:
    void read(const std::string& filename);
    void save_distances(std::string& file_name);
    void write(std::string& file_name);
    void write(std::ostream& os);
    void write_IDs(std::ostream& os) const;

private:
    std::list<Item*>     *l_items;
    std::list<Item*>::iterator l_first;
    std::list<Item*>::iterator l_last;

    std::vector<Item*>   *v_items;
    std::vector<Item*>::iterator l_first;
    std::vector<Item*>::iterator l_last;

    std::set<Item*>      *s_items;
    std::hash_map<Item*> *h_items;

    Container::Type container_type;
};
#endif
